<template lang="pug">
  .page
    Card
      p(slot="title")
        Icon.mr-10(type="md-time" size="20")
        | 操作日志
      Timeline
        TimelineItem(v-for="(item,index) in loggerList" :key="index")
          p
            span.time.mb-5 {{item.operateByName}} {{item.title}}
            span.font-12.ml-20 {{item.operateOn.slice(0, 19).replace(/T/g,' ')}}
            span.font-12.text-gray-9.ml-20 IP：{{item.ipAddress}}
      div(style="margin: 10px;overflow: hidden")
        .pull-right
          Page(:total="codeTotal" show-total :current="PageIndex" :page-size="PageSize" prev-text="上一页" next-text="下一页" @on-change="pageChangeFn")
</template>

<script>
import axios from 'axios'
import homeApi from '@/api/home.api.js'
export default {
  data () {
    return {
      loggerList: [],
      loggerSpin: true,
      PageIndex: 1,
      PageSize: 15,
      codeTotal: 0
    }
  },
  created () {
    this.getLogger()
    this.getCity()
  },
  methods: {
    getLogger () {
      homeApi.GetLogger({
        PageIndex: this.PageIndex,
        PageSize: this.PageSize
      }).then(res => {
        if (res.data.success) {
          this.loggerList = res.data.data
          this.loggerSpin = false
          this.codeTotal = res.data.totalRows
        } else {
          
          this.$Message.error({
            content: res.data.message,
            duration: 10,
            closable: true
          })
        }
      })
    },
    pageChangeFn (index) {
      this.PageIndex = index
      this.getLogger()
    }
  }
}
</script>

<style lang="less" scoped>
  .time{
    font-size: 16px;
    font-weight: bold;
  }
</style>
